/* 
 * File:   RuleOfThirdsBasedOnHue.cpp
 * Author: guilhermemg
 * 
 * Created on 12 de Fevereiro de 2012, 15:20
 */

#include "RuleOfThirdsBasedOnHue.h"

RuleOfThirdsBasedOnHue::RuleOfThirdsBasedOnHue() : RuleOfThirds() {
    setName("f5");
    setLargeName("f5 - ruleOfThirdsBasedOnHue");
}

RuleOfThirdsBasedOnHue::RuleOfThirdsBasedOnHue(const RuleOfThirdsBasedOnHue& orig) : RuleOfThirds(orig) {
}

RuleOfThirdsBasedOnHue::~RuleOfThirdsBasedOnHue() {
}

void RuleOfThirdsBasedOnHue::calculates() {
    double sum = 0;
    
    for(int i = this->getImage()->width/3; i <= 2*this->getImage()->width/3; i++) {
        uchar* ptr = (uchar*)(this->getImage()->imageData + i*this->getImage()->widthStep);
        for(int j = this->getImage()->height/3; j <= 2*this->getImage()->height/3; j++) {
            sum += ptr[3*j];
        }
    }
    
    sum = sum*2;
    
    setValue(9*sum/(double)(this->getImage()->height * this->getImage()->width));
}

